package com.ruoyi.system.entity.receivevo;

import cn.hutool.core.lang.UUID;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.constant.GlobalConstants;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.EnclosureAlert;
import com.ruoyi.system.domain.KeyAlert;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;

/**
 * 围栏报警对象 enclosure_alert
 * 
 * @author ruoyi
 * @date 2025-09-17
 */
@Data
public class ReceivePersonAlert implements Serializable
{
    private static final long serialVersionUID = 1L;

    private String id;
    private String companyCode;
    private String personId;
    private String zoneId;
    // sos报警：0，越界报警：1，滞留报警：2，静止报警：3，离场报警：4
    private String alarmType;
    private String longitude;
    private String latitude;
    private String alarmTime;
    private String dispelTime;
    // 报警描述， 必填
    private String describe;
    private String deleted;

    /** 创建人 */
    private String createdBy;
    /** 创建时间 */
    private String createDate;
    /** 创建人 */
    private String updateBy;
    /** 创建时间 */
    private String updateDate;

    public static ReceivePersonAlert enclosureAlertToReceivePersonAlert(EnclosureAlert enclosureAlert) {
        ReceivePersonAlert vo = new ReceivePersonAlert();
        vo.setId(UUID.randomUUID().toString());
        vo.setCompanyCode(GlobalConstants.COMPANY_CODE);
        String alarmTime = DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss", enclosureAlert.getRaiseTime());
        String dispelTime = DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss", enclosureAlert.getStopTime());
        vo.setAlarmTime(alarmTime);
        vo.setDispelTime(dispelTime);
        vo.setDescribe(enclosureAlert.getEnclosureName() + "内触发" + enclosureAlert.getTriggerName());
        vo.setDeleted("0");

//        vo.setPersonId();
//        vo.setZoneId();
//        vo.setLongitude(enclosureAlert.getLongitude());
//        vo.setLatitude(enclosureAlert.getLatitude());
//        vo.setCreatedBy(enclosureAlert.getCreatedBy());
//        String createTime = DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss", enclosureAlert.getCreatedTime());
//        String updateTime = DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss", enclosureAlert.getUpdateTime());
//        vo.setCreateDate(createTime);
//        vo.setUpdateBy(enclosureAlert.getUpdateBy());
//        vo.setUpdateDate(updateTime);
        return vo;
    }

    public static ReceivePersonAlert keyAlertToReceivePersonAlert(KeyAlert keyAlert) {
        ReceivePersonAlert vo = new ReceivePersonAlert();
        vo.setId(UUID.randomUUID().toString());
        vo.setCompanyCode(GlobalConstants.COMPANY_CODE);
        vo.setLongitude(keyAlert.getLon());
        vo.setLatitude(keyAlert.getLat());
        String alarmTime = DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss", keyAlert.getRaiseTime());
        String dispelTime = DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss", keyAlert.getStopTime());
        vo.setAlarmTime(alarmTime);
        vo.setDispelTime(dispelTime);
        vo.setDescribe(keyAlert.getTriggerName());
        vo.setDeleted("0");

//        vo.setPersonId();
//        String createTime = DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss", keyAlert.getCreatedTime());
//        String updateTime = DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss", keyAlert.getUpdateTime());
//        vo.setCreatedBy(keyAlert.getCreatedBy());
//        vo.setCreateDate(createTime);
//        vo.setUpdateBy(keyAlert.getUpdateBy());
//        vo.setUpdateDate(updateTime);
        return vo;
    }
}
